package com.yida.gwj.expend.outside.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yida.common.core.domain.R;
import com.yida.common.core.web.controller.BaseController;
import com.yida.common.core.web.domain.AjaxResult;
import com.yida.common.log.annotation.Log;
import com.yida.common.log.enums.BusinessType;
import com.yida.common.security.annotation.InnerAuth;
import com.yida.gwj.api.domain.dto.GwjExpendHouseAndOwnerDTO;
import com.yida.gwj.expend.outside.domain.request.GwjHouseAndOwnerRequest;
import com.yida.gwj.expend.outside.service.GwjExpendOutsideBaseHouseService;

import io.swagger.annotations.ApiOperation;

/**
 * @author hmh
 * @date 2023/06/17
 */
@RestController
@RequestMapping("/house/info")
public class GwjExpendOutsideBaseHouseController extends BaseController {

    @Autowired
    private GwjExpendOutsideBaseHouseService gwjExpendOutsideBaseHouseService;

    /**
     * 修改房屋业主业务信息
     * 
     * @param gwjHouseAndOwnerRequest
     * @return
     */
    @Log(title = "公维金支出外网[房屋业主修改]", businessType = BusinessType.UPDATE, systemName = "gwj")
    @PutMapping
    public AjaxResult updatBusinessHouseAndOwnerInfo(@RequestBody GwjHouseAndOwnerRequest gwjHouseAndOwnerRequest) {
        return toAjax(gwjExpendOutsideBaseHouseService.updatBusinessHouseAndOwnerInfoByBizId(gwjHouseAndOwnerRequest));
    }

    /**
     * 根据业务ID检测房屋业主信息是否空
     * 
     * @param bizId
     * @return
     */
    @GetMapping("chekOwnerInfo")
    public AjaxResult checkOwnerInfo(Long bizId) {
        return toAjax(gwjExpendOutsideBaseHouseService.checkOwnerInfo(bizId));
    }

    /**
     * 查询业务房屋类型
     */
    @GetMapping("/houseUseType")
    public AjaxResult houseUseType(Long bizId) {
        return AjaxResult.success(gwjExpendOutsideBaseHouseService.selectHouseUseType(bizId));
    }

    /**
     * 查询房屋业主投票列表
     * 
     * @param outServerIdentification 业务标识
     * @return
     */
    @InnerAuth
    @GetMapping("/selectHouseAndOwnerVoteInfo/{outServerIdentification}")
    @ApiOperation("查询房屋业主投票列表")
    public R<List<GwjExpendHouseAndOwnerDTO>> selectHouseAndOwnerVoteInfos(@PathVariable("outServerIdentification") String outServerIdentification) {

        return R.ok(gwjExpendOutsideBaseHouseService.selectHouseAndOwnerVoteInfos(outServerIdentification));
    }

}
